import request from '@/utils/request'

// 查询SQL脚本管理列表
export function listScript(query) {
  return request({
    url: '/reportworld/script/list',
    method: 'get',
    params: query
  })
}

// 查询SQL脚本管理详细
export function getScript(id) {
  return request({
    url: '/reportworld/script/' + id,
    method: 'get'
  })
}

// 新增SQL脚本管理
export function addScript(data) {
  return request({
    url: '/reportworld/script',
    method: 'post',
    data: data
  })
}

// 修改SQL脚本管理
export function updateScript(data) {
  return request({
    url: '/reportworld/script',
    method: 'put',
    data: data
  })
}

// 删除SQL脚本管理
export function delScript(id) {
  return request({
    url: '/reportworld/script/' + id,
    method: 'delete'
  })
}

// 初始化查询
export function init(data) {
  return request({
    url: '/reportworld/script/init',
    method: 'post',
    data: data
  })
}

// 审核SQL脚本管理
export function processSqlScript(id) {
  return request({
    url: '/reportworld/script/processSqlScript/' + id,
    method: 'get'
  })
}

// 退回QL脚本管理
export function rebutSqlScript(idList, approvalReason) {
  return request({
    url: '/reportworld/script/rebutSqlScript',
    method: 'post',
    data: {
      idList: idList,
      approvalReason: approvalReason,
    }
  })
}

// 检查SQL脚本
export function checkSqlScript(data) {
  return request({
    url: '/reportworld/script/checkSqlScript',
    method: 'post',
    data: data
  })
}
// 还原版本
export function reductionData(version) {
  return request({
    url: '/reportworld/script/reductionData/'+ version,
    method: 'get'
  })
}
